package com.ruoyi.common.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMqConfig {
    public static final String QUEUE_NAME = "paymentCallbackQueue";
    public static final String EXCHANGE_NAME = "paymentCallbackExchange";
    public static final String ROUTING_KEY = "paymentCallbackRoutingKey";

    public static final String PRE_PAYMENT_QUEUE = "prePaymentQueue";
    public static final String PRE_PAYMENT_EXCHANGE = "prePaymentExchange";
    public static final String PRE_PAYMENT_ROUTINGKEY = "prePaymentRoutingKey";





    @Bean
    public Queue queue() {
        return new Queue(QUEUE_NAME, true); // durable = true
    }

    @Bean
    public DirectExchange exchange() {
        return new DirectExchange(EXCHANGE_NAME);
    }

    @Bean
    public Binding binding(Queue queue, DirectExchange exchange) {
        return BindingBuilder.bind(queue).to(exchange).with(ROUTING_KEY);
    }

    @Bean
    public Queue queue2() {
        return new Queue(PRE_PAYMENT_QUEUE, true); // durable = true
    }

    @Bean
    public DirectExchange exchange2() {
        return new DirectExchange(PRE_PAYMENT_EXCHANGE);
    }

    @Bean
    public Binding binding2(Queue queue2, DirectExchange exchange2) {
        return BindingBuilder.bind(queue2).to(exchange2).with(PRE_PAYMENT_ROUTINGKEY);
    }





}